<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="/lib/layui-v2.6.3/css/layui.css" media="all">

    <script src="/lib/jquery-3.4.1/jquery-3.4.1.min.js" charset="utf-8"></script>
    <script src="/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
    <script src="/lib/jq-module/jquery.particleground.min.js" charset="utf-8"></script>
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
    <div class="layui-container">
        <div class="layui-row">
            <div class="layui-col-lg-offset3" layui-col-lg6>
                <div class="layui-form layuimini-form">
                    <form class="layui-form" action="" lay-filter="residentForm">
    
                        <div class="layui-form-item">
                            <label class="layui-form-label">请选择导入文件：</label>
                            <input type="hidden" name="excel" id="excel">
                            <div class="layui-input-block">
                                <button type="button" class="layui-btn" id="durl">
                                    <i class="layui-icon">&#xe67c;</i>上传文件
                                </button>
                                
                                <!-- <div class="layui-upload-list">
                                    <img style="width: 100px" class="layui-upload-img" id="demo1">
                                    <p id="demoText"></p>
                                </div> -->
    
                                <div style="width: 95px;">
                                    <div class="layui-progress layui-progress-big" lay-showpercent="yes" lay-filter="demo">
                                        <div class="layui-progress-bar" lay-percent=""></div>
                                    </div>
                                </div>
    
                            </div>
    
                        </div>
    <!-- 
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                                提示：请上传excel文件，文件名为“学生信息表.xlsx”
                            </div>
                        </div> -->
    
    
                    </form>
                </div>
    
            </div>
        </div>
    </div>
    
    
    
    <script>
        //Demo
        layui.use(['form','element','upload'], function () {
            var form = layui.form
                , $ = layui.jquery
                ,element = layui.element
                ,upload = layui.upload
                , laydate = layui.laydate;
    
            //日期   渲染上面 id 为 date 的 标签
            laydate.render({
                elem: '#date'
            });
    
            //执行实例
            var uploadInst = upload.render({
                elem: '#durl' //绑定元素
                ,accept: 'file' //普通文件
                ,exts: 'xlsx' //上传文件格式
                ,url: 'http://localhost:8080/resident/import' //上传接口
                
                ,done: function(res){
                    //上传完毕回调
                    if(res.code==0){
                      
                        // 关闭当前窗口
                        var iframeIndex = parent.layer.getFrameIndex(window.name);
                        parent.layer.msg("上传成功");
                        parent.layer.close(iframeIndex);
                    
                    }
    
                   // $('#demoText').html(''); //置空上传失败的状态
    
                }
              
                //进度条
                ,progress: function(n, elem, e){
                    element.progress('demo', n + '%'); //可配合 layui 进度条元素使用
                    if(n == 100){
                        layer.msg('上传完毕', {icon: 1});
                    }
                }
            });
    
    
            
        });
    </script>
</body>
</html>